package com.hnkywl.sts.webservice.bg.util;

import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.http.HTTPConstants;

import javax.servlet.http.HttpServletRequest;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-8-12
 * Time: 下午2:50
 * To change this template use File | Settings | File Templates.
 */
public class ClientIPUtil {
    /**
     * 获取客户端IP地址，如调用方的IP
     * 适用于axis发布的webservice
     *
     * @return
     */
    public static String getRemoteIp() {
        MessageContext context = MessageContext.getCurrentMessageContext();
        HttpServletRequest request = (HttpServletRequest) context.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
        return request.getRemoteAddr();
    }
}
